﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

public partial class SearchCertificate : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnSearch_Click(object sender, ImageClickEventArgs e)
    {
        string certificateName = txtCertificateName.Text.Trim();
        GetAllCertificates(certificateName);
    }

    private void GetAllCertificates(string certificateName)
    {
        string path= Server.MapPath("~/Products");
        DirectoryInfo di = new DirectoryInfo(path);        
        FileInfo[] aryFi= di.GetFiles();

        foreach (FileInfo fi in aryFi)
        {
            if (fi.Name == certificateName + fi.Extension)
            {                
                imgCertificate.ImageUrl = "~/Products/" + fi.Name;
                dvImage.Visible = true;
                imgCertificate.Visible = true;
                break;
            }
        }

    }
}